<?php
include_once('admin_global.php');
bn_include_lib('bn_jquery');
$theme->add_block('body');
$mod=new bn_module;
$grid=new bn_grid;
$grid->header->enable=true;
$grid->delete->enable=true;
$grid->delete->caption=$lang[11];
$grid->delete->cssclass='button red';

$cdir=new column;
$cdir->field_name='dir';
$cdir->caption=$lang[55];
$grid->columns->append($cdir);

$cname=new column;
$cname->field_name='name';
$cname->caption=$lang[61];
$grid->columns->append($cname);

$cmod=new column;
$cmod->caption=$lang[57];
$cmod->field_name='module';
$grid->columns->append($cmod);

$cact=new column;
$cact->caption=$lang[59];
$cact->template='<input type="submit" name="active" id="active" value="<%active%>" class="button"/>';
$grid->columns->append($cact);

if(isset($_FILES['file']))
$mod->module_add($_FILES['file']);

if($_POST['cmd'])
{
    extract($_POST);
    if($cmd=='delete')
    $mod->delete($id);
    if($cmd=='active')
    {
        if($state=='disable')
        $mod->module_install($dir);
        if($state=='enable')
        $mod->module_unistall($dir);
    }
    
    die($grid->show($mod->module_list()));
}
$theme->add_script(jquery_element('#active','click','
var dir=$(this).closest("tr").find("td:first").html();
$.post(window.location.href,{cmd:"active",dir:dir,state:$(this).val()},function(data){
    $("#show").html(data);
});'));

$theme->add_script($grid->command_script('#show'));
?>
<label><?php echo $lang[62] ?></label>
<input type="file" size="50" class="file" name="file" class="input-text"/>
<input type="submit" name="submit" id="submit" class="button" value="<?php echo $lang[63] ?>"/>
<div id="show">
<?php
	echo $grid->show($mod->module_list());
?>
</div>
<?php
$theme->render();
?>